package org.rmm.db;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import org.rmm.model.Order;

public enum Repository {
	INSTANCE;
	
	private Map<String,Order> repo = new HashMap<String, Order>(10);
	
	
	public void addOrder(Order o){
		repo.put(o.getId(), o);
	}
	
	public Order retrieveOrder(String id){
		return repo.get(id);
	}
	
	public void removeOrder(String id){
		repo.remove(id);
	}
	
	public Collection<Order> getOrders(){
		return repo.values();
	}

	public void updateOrder(Order o) {
		if (repo.containsKey(o.getId())){
			repo.put(o.getId(), o);
		}
	}

}
